import request from '@/utils/request.js'
import {ref} from 'vue'
//添加老师
export const TeacherAddService = (teacherData) => {
    return request.post('/teacher', teacherData)
}

//修改老师
export const TeacherUpdateService = (teacherData) => {
    return request.put('/teacher', teacherData)
}

//删除老师
export const TeacherDeleteService = (id) => {
    return request.delete('/teacher?id=' + id)
}


//搜索获取老师信息
export const TeacherListBySearchService = (input,select,currentPage,pageSize) =>{
    return request.get('/teacher/search', {
        params: {
            input: input,
            select: select,
            page: currentPage,
            size: pageSize
        }
    })
}


//修改密码
export const UpdatePasswordService = (userData) => {
    return request.put('/teacher/password', userData)
}


export const TeacherListAllSerivce = () =>{
    return request.get('/teacher/all')
}

export const fetchTeachersByProfession =(id) =>{
    return request.get('/teacher/fetch?id='+id)
}

//提供登录接口的函数
export const teacherLoginService = async (loginData) => {
    const teacherData = ref({
        teacherName:loginData.adminName,
        teacherPassword:loginData.adminPassword,
    })
    const response = await request.post('/teacher/login', teacherData.value);
    const jwtToken = response.data;
    localStorage.setItem('teacherJwtToken', jwtToken);
    return response;
}


//重置密码
export const teacherForgetPassService =(phone, pass, verify) => {
    return request.put(`/teacher/repass?phone=${phone}&pass=${pass}&verify=${verify}`);
}


//修改管理员数据
export const TeacherUpdateImgService = (userData) => {
    return request.put('/teacher/img', userData)
}